package com.hmsg.health.service.admin;


import com.hmsg.health.bean.Dto.SorderDto;
import com.hmsg.health.bean.domain.SorderDo;
import com.hmsg.health.bean.domain.UserDo;
import com.hmsg.health.dao.AdminSorderDao;
import com.hmsg.health.dao.UserDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.relational.core.sql.In;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class AdminSorderService {

    @Autowired
    private AdminSorderDao adminSorderDao;
    @Autowired
    private UserDao userDao;

    public List<SorderDto> findAll(String phone,String time,Integer firstResult,Integer maxResult) {
        List<SorderDto> sorderDtoList= adminSorderDao.findAll(phone,time,firstResult,maxResult);
        if(sorderDtoList != null && sorderDtoList.size()>0){
            for(SorderDto s:sorderDtoList){
                UserDo select = userDao.select(s.getUserId());
                s.setPhone(select.getMobile());
                s.setUserName(select.getUserName());
            }
        }
        return sorderDtoList;
    }
}
